package myblog.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;

import myblog.dao.ReviewDao;
import myblog.entity.ReviewEntity;
import myblog.vo.ReviewVo;

public class ReviewServiceImpl implements myblog.service.ReviewService {
	private ReviewDao dao = null;
	@Override
	public List<ReviewVo> list() {
		List<ReviewVo> voList = new ArrayList<ReviewVo>();

		List<ReviewEntity> entityList = dao.list();

		for (ReviewEntity entity : entityList) {

			ReviewVo vo = new ReviewVo();

			// 对象属性值拷贝 entity => vo
			BeanUtils.copyProperties(entity, vo);

			voList.add(vo);
		}

		return voList;
	}

	@Override
	public void addReview(ReviewVo reviewVo) {
		dao.addReview(reviewVo);
		
	}
	
	public void setDao(ReviewDao dao){
		this.dao = dao;
	}

}
